<template>
	<div>
		<el-form ref="form" :model="form" :rules="rules"  label-width="80px">
			<el-form-item label="护理级别" prop="levelName">
				<el-input v-model="form.levelName"></el-input>
			</el-form-item>

			<el-form-item label="状态" prop="levelStatus">
				<el-input v-model="form.levelStatus"></el-input>
			</el-form-item>

			<el-form-item>
				<el-button type="primary" plain @click="save">保存数据</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	import axios from '@/utils/axiosutils.js';
	export default {
		name: 'nurseLevelAdd',
		props: ['editid'],
		components: {},
		data() {
			return {
				form: {
					levelName: '',
					levelStatus: ''
				},
				rules:{
					levelName:[{required: true, message: '请输入', trigger: 'blur'}],
					levelStatus:[{required: true, message: '请输入', trigger: 'blur'}],
				},
			};
		},
		created() {
			if (this.editid) {
				// 如果是修改 用户名输入框禁用
				this.isupdate = true;
				axios.get(
					'/nurseLevel/getById',
					response => {
						this.form.id = this.editid;
						this.form.levelName = response.obj.levelName;
						this.form.levelStatus = response.obj.levelStatus;
					}, {
						id: this.editid
					}
				);
			}
		},
		methods: {
			save: function() {
				axios.post(
					'/nurseLevel/add',
					resp => {
						this.$emit('update:show', false);
						this.$emit('getData');
					},
					this.form
				);
			}
		}
	};
</script>

<style></style>
